package com.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {
	/**
	连接mysq1数据库的操作，用户名，密码，使用jdbc连接
	**/
	public static String username = "root";//账号
	public static String password = "root";//密码
	public static String database = "aaa";
	public static String url ="jdbc:mysql://localhost:3306/"+database+"?characterEncoding=utf-8";
	
	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch(ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
//	获取数据库连接
	public static Connection getConnectDb() {
		Connection conn = null;
		try{
			conn =DriverManager.getConnection(url,username,password);
		} catch(SQLException e) {
			e.printStackTrace();
			}
		return conn;
	}
		
		
}
	
	
	
